//////////////////////////////////////////////////////////////////////////////////
//                                                                              //
//  This file is part of the buola project (https://code.google.com/p/buola/).  //
//                                                                              //
//  Copyright(c) 2007-2011 Xavi Gratal                                          //
//  gratal AT gmail DOT com                                                     //
//                                                                              //
//  Buola is free software: you can redistribute it and/or modify               //
//  it under the terms of the GNU General Public License as published by        //
//  the Free Software Foundation, either version 3 of the License, or           //
//  (at your option) any later version.                                         //
//                                                                              //
//  Buola is distributed in the hope that it will be useful,                    //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of              //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               //
//  GNU General Public License for more details.                                //
//                                                                              //
//  You should have received a copy of the GNU General Public License           //
//  along with buola.  If not, see <http://www.gnu.org/licenses/>.              //
//                                                                              //
//////////////////////////////////////////////////////////////////////////////////

#ifndef _BUOLA_ITERATOR_END_H_
#define _BUOLA_ITERATOR_END_H_

#include <buola/iterator/facade.h>

namespace buola {

///\addtogroup iterators
///@{

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/// end-of-input iterator

/// Objects of this class can be used as the \e end iterator for certain input and forward
/// iterators for which the past-the-end information is contained within the iterator, and all
/// the past-the-end iterators are equal.
///
/// As it always mark the past-the-end it is not dereferenceable or incrementable.
///
/// It is also non-decrementable, which is the reason why it can only be used together with input and forward
/// iterators.
///
/// An example is the iterator returned by \ref split_end, which is of this type.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
class IEnd : public IFacade<IEnd,std::forward_iterator_tag,UUnused>
{
    friend class IFacade<IEnd,std::forward_iterator_tag,UUnused>;

public:
    ///constructs a past-the-end iterator
    IEnd()=default;
    
private:
    ///returns true, since all past-the-end iterators are equal.
    bool Equal(const IEnd&) const
    {
        return true;
    }
    
    ///it will be equal to the other iterator if the other iterator is equal to this.
    template<typename tIt>
    bool Equal(const tIt &pO) const
    {
        return pO.Equal(*this);
    }
};
    
///@}

/*namespace buola*/ }

#endif
